package com.chenglu.android.payment.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.LogUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.payment.bean.CouponListBean;
import com.chenglu.android.payment.bean.TenantIdPayMethod;

import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023 6 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：
 */
public class OrderPaytypeAdapter extends BaseQuickAdapter<TenantIdPayMethod.Data, BaseViewHolder> {

     Context mContext;
    public OrderPaytypeAdapter(Context context, int layoutResId, @Nullable List<TenantIdPayMethod.Data> data) {
        super(layoutResId, data);
        this.mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper,TenantIdPayMethod.Data item) {

        if(item==null){
            return;
        }
        ImageView ivPayIcone = helper.getView(R.id.iv_pay_icon);

        GlideUtils.setImageView(mContext,item.getIconImg(),ivPayIcone);

        helper.setText(R.id.tv_gold_money,item.getDescriptions());

        if(helper.getAdapterPosition() == getthisPosition()){

            helper.setBackgroundRes(R.id.iv_check,R.drawable.list_checkbox_select);

        }else {
            helper.setBackgroundRes(R.id.iv_check,R.drawable.list_checkbox_default);
        }
        if(item.getPayType().equals("3") || item.getPayType().equals("6")){
            helper.setText(R.id.tv_golded_balance,Utils.doubleTrans2(item.getBalance())+"")
                    .setGone(R.id.tv_golded_balance,true);
        }else if(item.getPayType().equals("6")){
            helper.setText(R.id.tv_golded_balance,Utils.doubleTrans2(item.getBalance())+"")
                    .setGone(R.id.tv_golded_balance,true);
            helper.setText(R.id.tv_discount,Utils.doubleTrans2(item.getDiscount())+"");

        }else {
            helper.setText(R.id.tv_golded_balance,Utils.doubleTrans2(item.getBalance())+"")
                    .setGone(R.id.tv_golded_balance,false);
        }

    }


    //先声明一个int成员变量,若为0默认显示第一个
    private int thisPosition = 0;



    //再定义一个int类型的返回值方法
    public int getthisPosition() {
        return thisPosition;
    }

    //   传入点击的位置
    public void setThisPosition(int thisPosition) {
        this.thisPosition = thisPosition;
        notifyDataSetChanged();
    }
}
